import json
import os.path

import tornado.web
import logging
import yaml
from art import text2art


from web.Handler import Server




def start_app():
    with open("resources/application.yml","r") as f:
        config = yaml.safe_load(f)
    logging.basicConfig(level=config["app"]["logLevel"],
                        format="%(asctime)s - %(levelname)s - %(message)s")
    logging.getLogger("ultralystics").disabled = True
    app = tornado.web.Application([
        (r"/elearning/opr",Server,dict(config=config))
    ])
    logging.info(f"{config['app']['name']} is running on {config['app']['httpPort']}")
    print(text2art(config["app"]["name"]))
    app.listen(config["app"]["httpPort"])
    tornado.ioloop.IOLoop.current().start()

if __name__ == '__main__':
    start_app()


